<template lang="">
    <div>
        <van-form>
            <van-field v-model='form.mobile' label='手机号' rules="[{'required':true,'message':'必须输入手机号'}]"/>
            <van-field v-model='form.password' label='密码' rules="[{'required':true,'message':'必须输入密码'}]"/>
            <van-button @click='login'>登录</van-button>
        </van-form>
    </div>
</template>
<script>
export default {
    data(){
        return{
            form:{},
        }
    },
    methods: {
        login(){
            this.axios.post('login',this.form).then(res=>{
                //登录成功后把id,localStorage
                localStorage.setItem('userid',res.data.id)
                localStorage.setItem('mobile',res.data.mobile)
                //登录成功后跳转
                this.$router.push({"path":'/userinfo'})
            })
        }
    },
}
</script>
<style lang="">
    
</style>